﻿// This code is released under the BSD license.
namespace PugLib.UnitTest
{
    #region

    using System;
    using System.Collections.Generic;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    #endregion

    /// <summary>
    ///This is a test class for ValidatedObjectTest and is intended
    ///to contain all ValidatedObjectTest Unit Tests
    ///</summary>
    [TestClass]
    public class ValidatedObjectTest
    {
        [TestMethod]
        public void ValueTest()
        {
            List<int> source = new List<int> { 0, 1, 2, 3, 4, 5 };
            Index negative = new Index(-1, source.Count);
            Index valid = new Index(0, source.Count);
            Index over = new Index(source.Count + 10, source.Count);

            Assert.AreEqual(source[valid.Value], 0);
            UnitTestHelper.TestException(() => { int target = source[negative.Value]; },
                                         typeof(InvalidOperationException));
            UnitTestHelper.TestException(() => { int target = source[over.Value]; }, typeof(InvalidOperationException));
        }
    }
}